package com.idanchuang.support.etcache.remote;

import com.idanchuang.support.etcache.EtCacheProperties;
import com.idanchuang.support.etcache.pressure.PressureChecker;
import com.idanchuang.support.etcache.pubsub.RemoteEventPublisher;
import com.idanchuang.support.etcache.pubsub.RemoteEventSubscriber;
import com.idanchuang.support.etcache.remote.codec.JavaValueCodec;
import com.idanchuang.support.etcache.remote.codec.ValueCodec;
import com.idanchuang.support.etcache.remote.codec.RemoteKeyCodec;

/**
 * 远程缓存对象的配置类
 *
 * @author yjy
 * Created at 2021/12/21 4:43 下午
 */
public class RemoteCacheConfig {

    protected ValueCodec keyCodec;
    protected ValueCodec valueCodec;
    protected final String cacheName;
    protected final RemoteKeyCodec remoteKeyCodec;
    protected final RemoteEventPublisher publisher;
    protected final RemoteEventSubscriber subscriber;
    protected final PressureChecker pressureChecker;

    protected final EtCacheProperties properties;

    public RemoteCacheConfig(String cacheName,
                             RemoteKeyCodec remoteKeyCodec,
                             RemoteEventPublisher publisher,
                             RemoteEventSubscriber subscriber,
                             PressureChecker pressureChecker, EtCacheProperties properties) {
        this(cacheName, new JavaValueCodec(), new JavaValueCodec(),
                remoteKeyCodec, publisher, subscriber, pressureChecker, properties);
    }

    public RemoteCacheConfig(String cacheName,
                             ValueCodec keyCodec, ValueCodec valueCodec,
                             RemoteKeyCodec remoteKeyCodec,
                             RemoteEventPublisher publisher,
                             RemoteEventSubscriber subscriber,
                             PressureChecker pressureChecker, EtCacheProperties properties) {
        this.cacheName = cacheName;
        this.keyCodec = keyCodec;
        this.valueCodec = valueCodec;
        this.remoteKeyCodec = remoteKeyCodec;
        this.publisher = publisher;
        this.subscriber = subscriber;
        this.pressureChecker = pressureChecker;
        this.properties = properties;
    }

    public RemoteEventPublisher getPublisher() {
        return publisher;
    }

    public ValueCodec getKeyCodec() {
        return keyCodec;
    }

    public ValueCodec getValueCodec() {
        return valueCodec;
    }

    public String getCacheName() {
        return cacheName;
    }

    public void setKeyCodec(ValueCodec keyCodec) {
        this.keyCodec = keyCodec;
    }

    public void setValueCodec(ValueCodec valueCodec) {
        this.valueCodec = valueCodec;
    }

    public RemoteEventSubscriber getSubscriber() {
        return subscriber;
    }

    public RemoteKeyCodec getRemoteKeyCodec() {
        return remoteKeyCodec;
    }

    public PressureChecker getPressureChecker() {
        return pressureChecker;
    }

    public EtCacheProperties getProperties() {
        return properties;
    }
}
